class Solution(object):
    def intersect(self, nums1, nums2):
        """
        :type nums1: List[int]
        :type nums2: List[int]
        :rtype: List[int]
        """
        dict1 = {}
        for num in nums1:
            if num not in dict1:
                dict1.update({num:0})
            dict1[num]+=1
        dict2 = {}
        for num in nums2:
            if num not in dict2:
                dict2.update({num:0})
            dict2[num]+=1
        
        results = []
        for num in dict1.keys():
            if num in dict2:
                for _ in range(min(dict1[num], dict2[num])):
                    results.append(num)
        return results
            